<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.9/vue.js"></script>
<style>
    .p1 {
        color: red;
        font-weight: 700;
    }

    .p2 {
        font-size: 50px;
    }
</style>

<body>
    <div id="app">
        <p v-bind:class="p1">{{msg}}</p>
        <!-- 直接用 -->
        <p :class="test">{{msg}}</p>
        <!-- 方法得调用 -->
        <p :class="test1()">{{msg}}</p>
        <p class="p1 p2">{{msg}}</p>
        <!-- 当class是动态时，有多个类名 多个类名存放到数组中 -->
        <p :class="[p1,p2]">{{msg}}</p>
        <!--当class是动态时,它的值可以是对象，对象的key为class名，该标签是否携带该class类名取决于后面的value -->
        <p :class="{p1:flag}">{{msg}}</p>


        <p v-if="flag" class="p1">{{msg}}</p>
        <p v-else class="p2">{{msg}}</p>

        <h1>style</h1>
        <p style="font-size: 50px;color:pink">{{info}}</p>
        <p :style="{fontSize,color}">{{info}}</p>
        <p :style="style">{{info}}</p>
        <p :style="style_test">{{info}}</p>
    </div>
    <script>
        let vm = new Vue({
            el: '#app',
            data: {
                msg: '张总发烧了，不舒服！！',
                info: '中午吃的药真苦！！',
                p1: 'p1',
                p2: 'p2',
                flag: true,
                fontSize: '30px',
                color: 'green',
                style: {
                    fontSize: '60px',
                    color: 'orange'
                }
            },
            methods: {
                test1() {
                    return this.flag ? this.p1 : this.p2
                }
            },
            computed: {
                test() {
                    return this.flag ? this.p1 : this.p2
                },
                style_test() {
                    return this.flag ? this.style : '';
                }
            }
        })
    </script>
</body>

</html>